package dipl.visualizer.graphics.shape;

import dipl.algorithm.math.fp.primitive.Point2df;
import dipl.visualizer.graphics.PaintContext;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Stroke;

public class LineSegmentShape extends AbstractShape {

	//
	// CONSTRUCTOR METHODS
	//
	
	/// <summary>
	/// Constructs line segment shape from given segment endpoints
	/// </summary>
	/// <param name="name"></param>
	/// <param name="a"></param>
	/// <param name="b"></param>
	/// <param name="color"></param>
	public LineSegmentShape( String name, Point2df a, Point2df b, Color color ) {
		super( name, color );
		this.a = a;
		this.b = b;
		this.stroke = new BasicStroke( 1.0f );
	}

	//
	// PUBLIC METHODS
	//
	
	@Override
	public void Paint( PaintContext pc ) {
		pc.SetColor( color );
		pc.SetStroke( stroke );
		pc.DrawLine(  a, b );
	}

	//
	// PROPERTIES
	//

	@Override
	public Point2df PointOnShape() {
		return new Point2df( (a.x+b.x)*0.5, (a.y+b.y)*0.5 );
	}

	//
	// MEMBERS
	//
	
	/// <summary>
	/// segment endpoint
	/// </summary>
	private Point2df a;
	/// <summary>
	/// segment endpoint
	/// </summary>
	private Point2df b;

	private Stroke stroke;
}
